package com.huangmb.anymark.app.activity.base;

import android.os.Bundle;
import android.util.Log;
import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.huangmb.anymark.app.activity.base.AppBaseActivity;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/4/15 15:33
 */
public class BaseMapActivity extends AppBaseActivity {
    protected MapView mapView;
    protected AMap aMap;

    public MapView getMapView() {
        return this.mapView;
    }

    public void setMapView(MapView mapView, Bundle savedInstanceState) {
        this.mapView = mapView;
        if (this.mapView != null) {
            this.aMap = this.mapView.getMap();
            this.aMap.getUiSettings().setMyLocationButtonEnabled(true);
            this.aMap.setMyLocationEnabled(true);
            this.mapView.onCreate(savedInstanceState);
            Log.d("setUpMapView","MapView created");
        }
    }

    public AMap getAMap() {
        return aMap;
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onResume() {
        super.onResume();
        if (mapView != null) {
            mapView.onResume();
        }
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onPause() {
        super.onPause();
        if (mapView != null) {
            mapView.onPause();
        }
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (mapView != null) {
            mapView.onSaveInstanceState(outState);
        }
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mapView != null) {
            mapView.onDestroy();
        }
    }

}
